package edu.jmu.action.attendance;




import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import edu.jmu.action.BaseAction;
import edu.jmu.bean.PageView;
import edu.jmu.bean.attendance.ManualSign;
import edu.jmu.bean.user.User;

import edu.jmu.service.attendance.ManualSignService;
import edu.jmu.utils.WebUtil;


@Controller
@Scope(value="prototype")
public class StatisticsManageAction extends BaseAction<ManualSign>{
	private static final long serialVersionUID = -4680298702412042355L;
	
	@Resource	
	 private ManualSignService manualSignService;	
	private String startDate;
	private String endDate;
	
	public String statistics(){
		/*pageView = new PageView<ManualSign>(maxresult,currentpage);
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		orderby.put("name", "desc");
		if(startDate !=null || endDate != null || "".equals(startDate) || "".equals(endDate)){
			String wherejpql = "o.signTime >=?1 and o.signTime <=?2";
			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
			try {
				pageView.setQueryResult(manualSignService.getScrollData(pageView.getFirstResult(), pageView.getMaxresult(),wherejpql,new Date[]{dateFormat.parse(startDate),dateFormat.parse(endDate)},orderby));
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}else{
			pageView.setQueryResult(manualSignService.getScrollData(pageView.getFirstResult(), pageView.getMaxresult(), orderby));
		}
		return "success";*/
		pageView = new PageView<ManualSign>(maxresult,currentpage);
		String wherejpql = "o.user = ?1";
		pageView.setQueryResult(manualSignService.getScrollData(pageView.getFirstResult(), pageView.getMaxresult(), 
				wherejpql,new User[]{WebUtil.getUser()}));		
		return SUCCESS;
	}

	/** set **/
	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}
	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}
	public String getStartDate() {
		return startDate;
	}
	public String getEndDate() {
		return endDate;
	}	
	
}

